<?php
$table = $this->uri->segment(3,0);
$url_ajax = base_url().'admin/ajax_field/order';
$url_ajax_sotrang = base_url().'admin/ajax_field/num';
$url_ajax_pub = base_url().'admin/ajax_field/pub/'.$table;
$url_ajax_where = base_url().'admin/ajax_field/where/'.$table;
?>
<script>
    $(document).ready(function(){
    //********************* loc du lieu***********************************
    $(".chon_danhmuc .locdulieu").change(function () {       
        //$('.loading').html('fdsfds');
        var data= $(this).val();
        var url2 = '<?php echo $url_ajax_where;?>';
        $.ajax({
          		type: "POST",
          		url: url2,
          		data: {data: data},
                success: callback,
                error: err
        		});
         
        return false;
    });
    function succes (data, status){
       // var id = '#p'+data;
        //alert(id);
        $(data).toggleClass('unpublish');
    }
    function callback(data, status){
        location.reload();
        //$("div .box_ajax").html(data);
      }
    
	function err(xhr, reason, ex){
	   alert('loi');
        $("div .box_ajax").html('loi');
      }
    });
    //*********************chon so trang**********************************
</script>
<div id="main-content">
    <div class="container">
    	<div class="row">
    		<div id="content" class="col-lg-12">
    			<!-- PAGE HEADER-->
                    <div class="row">
							<div class="col-sm-12">
								<div class="page-header">
									<div class="clearfix">
										<h3 class="content-title pull-left">Quản lí Câu hỏi</h3>
									</div>
								</div>
							</div>
					</div>
                    <!-- DATA TABLES -->
						<div class="row">
							<div class="col-md-12">
								<!-- BOX -->
								<div class="box border green">
									<div class="box-title">
										<h4><i class="fa fa-table"></i>Danh sách Câu hỏi</h4>
										<div class="tools hidden-xs">
											<a href="javascript:;" data-toggle="tooltip" title="Ẩn đi" class="collapse">
												<i class="fa fa-chevron-up"></i>
											</a>
										</div>
									</div>
									<div class="box-body">
										<table id="datatable1" cellpadding="0" cellspacing="0" border="0" class="datatable table table-striped table-bordered table-hover">
											<thead>
												<tr>
                                                    <th>ID</th>
													<th>Môn học</th>
													<th class="hidden-xs">Câu hỏi</th>
													<th class="center">Đáp án đúng</th>
													<th class="center">Sửa</th>
													<th class="center">Xóa</th>
												</tr>
											</thead>
                                            <?php 
                                            if(!empty($data)){
                                                foreach ($data as $data) :
                                            ?>
											<tbody>
												<tr class="gradeX">
													<td><?php echo $data->id;  ?></td>
													<td><?php echo $this->common_model->getone('subjects',array('id'=>$data->id_subjects))->title;  ?></td>
													<td><?php echo $data->content;  ?></td>
													<td class="center"><?php if($data->dung == 1) {echo 'A';}elseif($data->dung == 2) {echo 'B';}elseif($data->dung == 3) {echo 'C';}elseif($data->dung == 4) {echo 'D';}  ?></td>
													<td class="center"><a href="<?php echo base_url().'admin/xuly/question_test/edit/'.$data->id?>" title="Sửa danh mục <?php echo $data->title;  ?>"><i class="fa fa-edit fa-2x"></i></a></td>
                                                    <td class="center"><a onclick="return confirm('Bạn có muốn xóa không?');" href="<?php echo base_url().'admin/xuly/question_test/xoa/'.$data->id?>" title="Xóa danh mục <?php echo $data->title;  ?>"><i class="fa fa-trash-o fa-2x red"></td>
												</tr>
											</tbody>
                                            <?php endforeach; } ?>
										</table>
                                        <div class="row">
                                               <div class="col-sm-12">
                                                  <div class="pull-left">
                                                        <div class="chon_danhmuc">
                                                            Lọc dữ liệu:
                                                            <?php $mon=$this->common_model->getdata('subjects',array('publish'=>1));?>
                                                            <select name="cat" class="locdulieu">
                                                                <option <?php if($this->session->userdata('all_article') == 1){echo 'selected="selected"';}?> value="all" class="locked">Chọn tất cả</option> 
                                                                <?php 
                                                                    echo $value_where = $this->session->userdata('value_where');
                                                                        echo $this->session->userdata('all_article');
                                                                        if(!empty($mon)){
                                                                            foreach($mon as $cat){
                                                                                echo '<option value="'.$cat->id.'" class="locked"';
                                                                                echo $value_where==$cat->id?'selected="selected"':''; 
                                                                                echo '>'.$cat->title.'</option>';
                                                                            }
                                                                        }
                                                                        ?>
                                                                ?>
                                 
    
                                                            </select> 
                                                            </div>  
                                                  </div>
                                                  <div class="pull-right">
                                                           <?php echo $this->pagination->create_links();?>
                                                  </div>
                                                  <div class="clearfix"></div>
                                               </div>
                                            </div>
                                        <a href="<?php echo base_url().'admin/xuly/question_test/edit'; ?>" title="Thêm mới" class="btn btn-success"><i class="fa fa-angle-double-right"></i>&nbsp;&nbsp;&nbsp;Thêm mới</a>
									</div>
								</div>
								<!-- /BOX -->
							</div>
						</div>
						<!-- /DATA TABLES -->
   			</div>
    			<!-- /PAGE HEADER -->
    		</div>
    	</div>
</div>